package cn.duli.xianer.controller;

import cn.duli.xianer.pojo.MyResult;
import cn.duli.xianer.pojo.Transfer;
import cn.duli.xianer.service.TransferService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/transfer")
public class TransferController {

    @Autowired
    private TransferService transferService;

    /**
     * 分页查询转账列表
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/findAll")
    @RequiresRoles("admin")
    public MyResult findAll(@RequestParam(defaultValue = "1") int pageNo,
                                 @RequestParam(defaultValue = "6") int pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        PageInfo<Transfer> pageInfo = new PageInfo<>(transferService.findAll());
        return new MyResult(200, "分页查询转账列表",null,null,null,pageInfo);
    }
}
